package jupitermouse.site.scala
import org.apache.flink.api.scala.ExecutionEnvironment

object BatchWCScalaApp {

  def main(args: Array[String]): Unit = {
    //文件路径
    val inputPath = "file:///E:\\workroom\\hdsp\\flink_demo\\resource\\wordcount\\word.txt"
    //环境变量
    val env = ExecutionEnvironment.getExecutionEnvironment
    //读取数据源
    val datasource = env.readTextFile(inputPath)
    // 引入隐式转换
    import org.apache.flink.api.scala._
    //转换操作
    datasource.flatMap(_.toLowerCase.split(" "))
      .filter(_.nonEmpty)
      .map((_, 1))
      .groupBy(0)
      .sum(1)
      .print()
  }
}
